package org.empire.wicket;





import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.empire.model.MenuItem;
import org.empire.model.WebSite;

/**
 * Homepage
 */
public class BasePage extends WebPage {

	private static final long serialVersionUID = 1L;

	private WebSite website = new WebSite();
	
	// TODO Add any page properties or variables here

    /**
	 * Constructor that is invoked when page is invoked without a session.
	 * 
	 * @param parameters
	 *            Page parameters
	 */
    public BasePage(final PageParameters parameters) {
    	add(new ListView<MenuItem>("menu", website.getMenu().getItems()) {

			@Override
			protected void populateItem(ListItem<MenuItem> item) {
				MenuItem menuItem = item.getModelObject();
				menuItem.setDestination(BasePage.class);
				BookmarkablePageLink<MenuItem> link = new BookmarkablePageLink<MenuItem>("link", menuItem.getDestination());
				link.add(new Label("caption", menuItem.getDisplayName()));
				item.add(link);
			}
		});
       
    }
}
